package vue.stage;

import java.awt.FlowLayout;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import metier.Stage;
import ctr.commun.CommunGest;
import ctr.stage.GestModifStage;

public class JPanModifStage extends JPanel{

	private static final long serialVersionUID = -8258905260255616984L;
	private JComboBox jComboBox;
	private JTextField jtf_NomStage;
	
	public JPanModifStage(String titre) {
		CommunGest communGest = new CommunGest();
		// Recuperation de la liste des stages
		ArrayList<Stage> lStage = communGest.getListeStage();
		
		// Creation de la comboBox liste de stage.
		jComboBox = new JComboBox(lStage.toArray());
		JButton jButtonModif = new JButton("Modifier");
		jButtonModif.addActionListener(new GestModifStage(this));
		
		// Label
		JLabel lbl_NomStage = new JLabel("Nouveau nom : ");
		jtf_NomStage = new JTextField(15);
		
		// Ajout des differents composants.
		this.setBorder(new TitledBorder(titre));
		this.setLayout(new FlowLayout());
		this.add(lbl_NomStage);
		this.add(jtf_NomStage);
		this.add(jComboBox);
		this.add(jButtonModif);
	}

	public JComboBox getjComboBox() {
		return jComboBox;
	}

	public JTextField getJtf_NomStage() {
		return jtf_NomStage;
	}
}
